// components/count/count.js
Component({

  /**
   * 组件的初始数据
   */
  data: {
    count: 1
  },

  /**
   * 组件的方法列表
   */
  methods: {
    declineCount: function () {
      var myEventDetail = {}; // detail对象，提供给事件监听函数
      if (this.data.count > 1) {
        this.setData({
          "count": --this.data.count
        })
      }
      myEventDetail.count = this.data.count;
      this.triggerEvent('changeCount', myEventDetail);
    },
    addCount: function () {
      var myEventDetail = {}; // detail对象，提供给事件监听函数
      if (this.data.count < 99) {
        this.setData({
          "count": ++this.data.count
        });
        myEventDetail.count = this.data.count;
        this.triggerEvent('changeCount', myEventDetail);
      } 
    }
  }
})
